from telnetlib import DO
from manim import *
from numpy import flip, insert
import math

LV, QL, QH, JH = '#75cfb8', '#bbdfc8', '#f0e5d8', '#ffc478'


class p1(MovingCameraScene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        t = 0.9
        house=SVGMobject('./svgs/house.svg').scale(0.3).set_stroke(width=1).shift(UR*0.5*t)
        vg=VGroup()
        for i in range(8):
            for j in range(8):
                s=Square(1).shift(RIGHT*i+DOWN*j)
                if (i+j)%2==0:
                    s.set_fill(GRAY,1)
                vg.add(s)
        vg.move_to(ORIGIN).scale(t)
        self.add(vg)
        self.add(house)
        self.wait()

class p2(MovingCameraScene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        t=0.9
        house=SVGMobject('./svgs/house.svg').scale(0.3).set_stroke(width=1).shift(UR*0.5*t)
        vg=VGroup()
        for i in range(8):
            for j in range(8):
                s=Square(1).shift(RIGHT*i+DOWN*j)
                if (i+j)%2==0:
                    s.set_fill(GRAY,1)
                vg.add(s)
        vg.move_to(ORIGIN).scale(t)
        self.add(vg)
        self.add(house)
        # p2
        s_LV=Square(1).scale(t).shift(UP*3.5*t,RIGHT*0.5*t).set_fill(LV,1)
        s_JH=Square(1).scale(t).shift(UP*2.5*t,RIGHT*0.5*t).set_fill(JH,1)
        s_BLUE=Square(1).scale(t).shift(UP*1.5*t,RIGHT*0.5*t).set_fill(BLUE,1)
        self.add(s_LV,s_JH,s_BLUE,
                 s_LV.copy().shift(DOWN*2*t+RIGHT*t),
                 s_JH.copy().shift(DOWN*2*t+RIGHT*t),
                 s_BLUE.copy().shift(UP*2*t+RIGHT*t)
                 )
        vg_8=VGroup()
        for i in range(4):
            for j in range(2):
                s=Square().stretch(2,1).shift(RIGHT*i*2+DOWN*j*4).set_color(RED).set_stroke(width=8)
                vg_8.add(s)
        vg_8.move_to(ORIGIN).scale(t)
        self.add(vg_8,
                 house.copy().shift(UP*2*t+RIGHT*1*t),
                 )
        self.wait()